#ifndef _TASK_H_
#define _TASK_H_

#include "list.h"

//#define	PS_STACK_START		(0x80000000)
#define	PS_STACK_START		(0x300011000)
#define	PS_ENTRY				(0x10000000)

#define	PRIO_HIGH				(100)
#define	PRIO_NORMAL				(50)
#define	PRIO_IDLE				(1)
#define	NICE_MIN				(-20)
#define	NICE_MAX				(20)

typedef struct _os_pcb
{
	unsigned int *sp;			//process kernel mod stack;内核栈
	unsigned int pid;    		//process id;
	int timeSlice;	 			//process time slice;
	unsigned char stat;			//process stat;
	unsigned char	prio;		//process priority;
	unsigned int	ttBase;		//mmu page table;
	int	sleepTime;				//sleep time from switch out to switch in;
	int runTime;				//run time from switch in to switch out;
	int sleep_avg;				//depend on this to judge this process if is a interactive process;
	unsigned int timestamp;		//store the moment when the process switch;
	int	nice;					//nice range: -20 to 20;
	//file *executable;			//process code from this excutable file;
	struct list_head list;		//process list;	
	struct list_head ps_list;	//ALL exist process list;
}os_pcb;

typedef struct _os_runqueue
{
	unsigned long	nr_running;			//the number of running process;
	unsigned long	nr_expired;
	unsigned long	nr_switches; 		//every switch it increase;
	struct list_head	*active;		//active process queue in which process stat is PS_RUNNING ;
	struct list_head	*expired;		//expired process queue in which process use up own time slice;
	struct list_head	*curr;			//current process in running;
	struct list_head 	*exist;			//ALL exist process list;
}os_runqueue;

extern void init_pcb_list(void);
extern void Task1(void);
extern void Task2(void);
extern void Task3(void);
extern unsigned int CreateTask(unsigned int task);
extern void InitData(void);

#endif
